<template>
    <Modal
        v-model="showedit"
        title="重复数据"
        :mask-closable="false"
        :width="80"
        @on-cancel="handleCancel"
    >
        <Table :columns="columns" :data="data" :loading="loading"
        max-height="400">
            <template slot-scope="{ row }" slot="mobile">
                <p v-if="row.repeat_mobile">
                    <span v-for="(item, index) in row.mobiles" :key="index">
                        <font color="#ed4014" v-if="row.repeat_mobile_arr.indexOf(item)>=0">{{item}}</font>
                        <font v-else>{{item}}</font>
                        <font>{{index === row.mobiles.length-1?'':','}}</font>
                    </span>
                </p>
                <p v-else>
                    {{ row.mobiles.join(',') }}
                </p>
            </template>
            <template slot-scope="{ row }" slot="wechat_num">
                <font
                    v-if="row.repeat_wechat"
                    color="#ed4014"
                >
                    {{ row.wechat_id }} </font
                ><span v-else>{{ row.wechat_id }}</span>
            </template>
            <template slot-scope="{ row }" slot="dy_num">
                <font
                    v-if="row.repeat_dy"
                    color="#ed4014"
                >
                    {{ row.dy_num }} </font
                ><span v-else>{{ row.dy_num }}</span>
            </template>
            <template slot-scope="{ row }" slot="patient_data_type">
                <span v-if="row.patient_data_type == 1">鱼池</span>
                <span v-else-if="row.patient_data_type == 2">公海</span>
                <span v-else-if="row.patient_data_type == 0">患者</span>
            </template>
            <template slot-scope="{ row }" slot="state">
                <Tag v-if="row.status_name === '失效'" color="blue">{{
                    row.status_name
                }}</Tag>
                <Tag v-else-if="row.status_name === '跟进中'" color="volcano">{{
                    row.status_name
                }}</Tag>
                <Tag v-else-if="row.status_name === '预约'" color="cyan">{{
                    row.status_name
                }}</Tag>
                <Tag v-else-if="row.status_name === '到诊'" color="green">{{
                    row.status_name
                }}</Tag>
                <Tag
                    v-else-if="row.status_name === '已到老患者'"
                    color="orange"
                    >{{ row.status_name }}</Tag
                >
                <Tag v-else-if="row.status_name" color="orange">{{
                    row.status_name
                }}</Tag>
            </template>
        </Table>
        <div slot="footer">
            <Button @click="handleCancel">取消保存</Button>
            <Button type="primary" @click="handleSubmit">确定保存</Button>
        </div>
    </Modal>
</template>

<script>
import { patientindexrepeatconfirmlist } from "@/api/hqapi";
export default {
    data() {
        return {
            columns: [
                {
                    title: "基本信息",
                    key: "user_name",
                    minWidth: 155,
                    fixed: "left",
                },
                {
                    title: "手机号",
                    slot: "mobile",
                    width: 130,
                },
                {
                    title: "微信号",
                    slot: "wechat_num",
                    minWidth: 100,
                },
                {
                    title: "抖音号",
                    slot: "dy_num",
                    minWidth: 100,
                },
                { title: "重复类型", key: "patient_data_type", slot: "patient_data_type", minWidth: 100 },
                { title: "人员状态", key: "state", slot: "state", minWidth: 100 },
                {
                    title: "归属人",
                    key: 'realname',
                    minWidth: 130,
                },
                { title: "创建时间", key: "created_at_str", minWidth: 170 },
            ],
            loading: false,
            showedit: false,
            data: [],
            params: {
            },
        };
    },
    methods: {
        initial(params) {
            let arr1 = [1,2,3]
            let arr2 = [1]
            for (let item of arr1){
                // console.log(arr2.indexOf(item))
            }
            this.params = params
            this.askData()
        },
        askData() {
            this.loading = true
            patientindexrepeatconfirmlist(this.params).then((res) => {
                this.data = res.list
                if (this.data.length) {
                    this.showedit = true
                } else {
                    this.showedit = false
                    this.$emit('submitfun')
                }
                this.loading = false
            });
        },
        handleSubmit(){
            this.showedit = false
            this.$emit('submitfun')
        },
        handleCancel(){
            this.data = [];
            this.showedit = false
            this.$emit('cancelfun')
        },
    },
};
</script>

<style lang="less" scoped></style>
